#ifndef EXPRESSIONPARSER_H
#define EXPRESSIONPARSER_H

//
// Created by lix on 2024/5/19.
//
/*表达式解析器
 * 用于解析输入的表达式*/
#include <iostream>
#include <vector>
#include <string>
#include <functional>
#include <algorithm>
#include <sstream>

using namespace std;

#define elementType int

class ExpressionParser {
public:
    ExpressionParser(const string& expression) : expr(expression), pos(0) {}

    elementType parse();

    function<elementType(elementType, elementType)> getFunction();

    void setExpr(const string &expression);
private:
    string expr;
    size_t pos;
    elementType a, b;

    elementType parseExpression();

    elementType parseTerm();

    elementType parseFactor();
};




#endif // EXPRESSIONPARSER_H
